import Vue from 'vue';
import Vuex from 'vuex';
import collection from "./serilazable/collection.js";
import image from "./blob/image.js";
import persistedstate from "vuex-persistedstate"

Vue.use(Vuex);
const genertor_function = (fieldsName) => {
    return {
        [`s${fieldsName}`](status, new_value){
            status[fieldsName] = new_value
        }
    }
}

export default new Vuex.Store({
    state: {
        userstatus: {
            username: null,
            init: null
        },
    },
    mutations: {
        suserstatus(state, payload) {
            state.userstatus = payload;
        },
        ...genertor_function("userstatus")
    },
    actions: {},
    modules: {
        collection,
        image
    },
    plugins: [
        persistedstate
    ]
});
